#!/usr/bin/perl
use strict;
package nsinfo;

sub nsinfo {
    my $dbh = shift;
    my $recv = shift;
    my $tmpnum = shift;
    my $nsnum = shift;
    my $remote = shift;
#GET RNICK INFO
    my $sth = $dbh->prepare("SELECT rnick,email,showmail,lasthost,lastseen FROM nicks WHERE rnick = '$recv';");
    $sth->execute;
    my @info = $sth->fetchrow_array;

    if ($recv eq "") {
	print $remote "$nsnum O $tmpnum :Syntax :INFO <nick>\n";
    }
    elsif ($info[0] eq "") {
	print $remote "$nsnum O $tmpnum :Nickname \cB$recv\cB is not registered.\n";
    }
    else {
	my $notic = "$nsnum O $tmpnum";
	print $remote "$notic :NickName INFO For $recv\n";
	print $remote "$notic :Rnick     :$info[0]\n";
	print $remote "$notic :Email     :$info[1]\n" if ($info[2] ne '0');
	print $remote "$notic :Last Host :$info[3]\n";
	$info[4] = localtime($info[4]);
	print $remote "$notic :Last Seen :$info[4]\n";
	undef $notic;
    }
    undef @info;
    undef $recv;
}
1;
